DiffstoreBuilder<TKey, TValue>

Class

Namespace: Diffstore

Declared in: Diffstore


The main starting point, used to create a IDiffstore<TKey, TValue> instance.

Type parameters

TKey

The type used as entity key. All numeric types and strings are supported. Any IComparable with a corresponding string representation should work.

TValue

The entity value, a class which contains the data that need to be stored. Must be a class with a parameterless constructor.

Members

Method

  • Setup()
  • WithDiskStorage(string)
  • WithFileBasedEntities(FileFormat, FilesystemStorageOptions, IFileSystem)
  • WithFileBasedEntities(FilesystemStorageOptions, IFileSystem)
  • WithFileBasedEntities<TIn, TOut>(IFormatter<TIn, TOut>, FilesystemStorageOptions, IFileSystem)
  • WithLastFirstOptimizedSnapshots(IFileSystem, FilesystemStorageOptions, int)
  • WithMemoryStorage()
  • WithSingleFileSnapshots(FileFormat, IFileSystem, FilesystemStorageOptions)
  • Remarks

    This API may change in the near future to allow function calls in any order.

    Examples

    To create a new instance, first, choose a storage option - it's either WithMemoryStorage() or WithDiskStorage(string) :

    
    var db = new DiffstoreBuilder<long, MyData>()
    .WithDiskStorage();
    

    Then you should use the type of storage for entities and snapshots. At this time all entities are file-based, but in the future they may be stored in relational databases or something other. Available formats are defined in FileFormat .

    There are several mechanisms snapshot storage - currently implemented are "single file per snapshot" (see FileFormat ) and "last in, first out" (optimized binary storage).

    For example, to store your entities and snapshots in JSON files:

    
    var db = new DiffstoreBuilder<long, MyData>()
    .WithDiskStorage()
    .WithFileBasedEntities(FileFormat.JSON)
    .WithSingleFileSnapshots(FileFormat.JSON);
    .Setup();
    
    And that's it! Now you can use the storage as you like. Check out the IDiffstore<TKey, TValue> interface to see what can you do.

    See also

  • IDiffstore<TKey, TValue>
  • FileFormat

  • Back to index